<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增缴费单')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-bill-add">
            <div class="form-group">
                <label class="col-sm-3 control-label">账单派发类型：</label>
                <div class="col-sm-8">
                    <select class='form-control'  id='sendType' name='sendType'>
                        <option value="1">按年级派发</option>
                        <option value="2">按学生派发</option>
                    </select>

                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">学年：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                        <input name="schoolYear" class="form-control" placeholder="请选择学年" type="text"  th:value="${year}" required>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">学期：</label>
                <div class="col-sm-8">
                        <!--<input name="term" class="form-control" type="number" value="1"> <span class="input-group-addon">学期</span>-->
                        <select class='form-control' name='term' required>
                            <option value="1">第一学期</option>
                            <option value="2">第二学期</option>
                        </select>
                </div>
            </div>
            <div class="form-group" id="select_student">
                <label class="col-sm-3 control-label">选择学生：</label>
                <div class="col-sm-8">
                    <input id="studentName"  name="userNames" class="form-control" type="text" onclick="selectStudent()">
                    <input id="studentId" name="userIds" class="form-control" type="hidden" >

                </div>
            </div>
            <div class="form-group" id="select_grade">
                <label class="col-sm-3 control-label">选择缴费年级：</label>
                <div class="col-sm-8">
                    <input id="gradeName" name="gradeName"  type="hidden">
                    <select class='form-control selectpicker' data-live-search="true" id='gradeId' name='gradeId' required>
                    </select>
                </div>
            </div>



            <div class="form-group">    
                <label class="col-sm-3 control-label">缴费类型：</label>
                <div class="col-sm-8">
                    <select id="paymentCategory" name="paymentCategory" class="form-control m-b" th:with="type=${@dict.getType('sc_payment_category')}" required>
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">费用：</label>
                <div class="col-sm-8">
                    <div class="input-group">
                        <input name="amount" class="form-control" type="number" required> <span class="input-group-addon">元（RMB）</span>
                    </div>
                </div>
            </div>



        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <script th:src="@{/js/common/add_grade.js}"></script>
    <script type="text/javascript">
        var prefix = ctx + "school/bill"
        $("#form-bill-add").validate({
            focusCleanup: true
        });
        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-bill-add').serialize());
            }
        }

        $("input[name='schoolYear']").datetimepicker({
            format: "yyyy",
            autoclose: true,
            startView:4,
            minView:4,
            todayHighlight:true
        });

        $("input[name='paymentTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        function selectStudent(){
            $.modal.open("选择学生", ctx + "school/student" + "/query");
        }
           $(document).ready(function () {
            $("#select_student").hide();
            $('#sendType').change(function(){
                if($(this).val() == 1){
                    $("#select_student").hide();
                    $("#select_grade").show();
                }else{
                    $("#select_student").show();
                    $("#select_grade").hide();
                }

            });
        });
    </script>
</body>
</html>